package com.neusoft.neuiotms.dcom.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcom.model.Config;
import com.neusoft.neuiotms.dcom.repository.ConfigRepository;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("配置管理")
@RestController
@RequestMapping(value = "/api/w/configs")
public class ConfigController {

    @Autowired
    private ConfigRepository configRepository;

    @ApiOperation("配置详情")
    @GetMapping("/{code}/data")
    public ResultDTO<String> getData(@PathVariable final String code) {
        final Config config = this.configRepository.findOneByCode(code);
        return ResultDTO.success(null == config ? "" : config.getData());
    }

}
